package leetcode.每日一题;

import org.junit.Test;

import java.util.*;

/**
 * @author ：zsy
 * @date ：Created 2022/3/20 16:35
 * @description：https://leetcode-cn.com/problems/jewels-and-stones/
 */
public class 宝石与石头 {
    @Test
    public void test() {
        Solution solution = new Solution();
    }

    class Solution {
        public int numJewelsInStones(String jewels, String stones) {
            HashSet<Character> set = new HashSet<>();
            for (char ch : jewels.toCharArray()) {
                set.add(ch);
            }
            int ans = 0;
            for (char ch : stones.toCharArray()) {
                if (set.contains(ch)) {
                    ans++;
                }
            }
            return ans;
        }
    }

}
